import 'package:enterprise_v6_app/generated/json/base/json_convert_content.dart';
import 'package:enterprise_v6_app/app/data/entities/common/principal_responsibilities_list_entity.dart';

PrincipalResponsibilitiesListEntity $PrincipalResponsibilitiesListEntityFromJson(Map<String, dynamic> json) {
  final PrincipalResponsibilitiesListEntity principalResponsibilitiesListEntity = PrincipalResponsibilitiesListEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    principalResponsibilitiesListEntity.id = id;
  }
  final String? companyCode = jsonConvert.convert<String>(json['companyCode']);
  if (companyCode != null) {
    principalResponsibilitiesListEntity.companyCode = companyCode;
  }
  final String? typeName = jsonConvert.convert<String>(json['typeName']);
  if (typeName != null) {
    principalResponsibilitiesListEntity.typeName = typeName;
  }
  final dynamic path = json['path'];
  if (path != null) {
    principalResponsibilitiesListEntity.path = path;
  }
  final String? parentId = jsonConvert.convert<String>(json['parentId']);
  if (parentId != null) {
    principalResponsibilitiesListEntity.parentId = parentId;
  }
  final String? createBy = jsonConvert.convert<String>(json['createBy']);
  if (createBy != null) {
    principalResponsibilitiesListEntity.createBy = createBy;
  }
  final dynamic createById = json['createById'];
  if (createById != null) {
    principalResponsibilitiesListEntity.createById = createById;
  }
  final String? createDate = jsonConvert.convert<String>(json['createDate']);
  if (createDate != null) {
    principalResponsibilitiesListEntity.createDate = createDate;
  }
  final String? updateBy = jsonConvert.convert<String>(json['updateBy']);
  if (updateBy != null) {
    principalResponsibilitiesListEntity.updateBy = updateBy;
  }
  final dynamic updateById = json['updateById'];
  if (updateById != null) {
    principalResponsibilitiesListEntity.updateById = updateById;
  }
  final String? updateDate = jsonConvert.convert<String>(json['updateDate']);
  if (updateDate != null) {
    principalResponsibilitiesListEntity.updateDate = updateDate;
  }
  final String? deleted = jsonConvert.convert<String>(json['deleted']);
  if (deleted != null) {
    principalResponsibilitiesListEntity.deleted = deleted;
  }
  final bool? isExpand = jsonConvert.convert<bool>(json['isExpand']);
  if (isExpand != null) {
    principalResponsibilitiesListEntity.isExpand = isExpand;
  }
  final List<PrincipalResponsibilitiesListEntity>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PrincipalResponsibilitiesListEntity>(e) as PrincipalResponsibilitiesListEntity).toList();
  if (children != null) {
    principalResponsibilitiesListEntity.children = children;
  }
  return principalResponsibilitiesListEntity;
}

Map<String, dynamic> $PrincipalResponsibilitiesListEntityToJson(PrincipalResponsibilitiesListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['companyCode'] = entity.companyCode;
  data['typeName'] = entity.typeName;
  data['path'] = entity.path;
  data['parentId'] = entity.parentId;
  data['createBy'] = entity.createBy;
  data['createById'] = entity.createById;
  data['createDate'] = entity.createDate;
  data['updateBy'] = entity.updateBy;
  data['updateById'] = entity.updateById;
  data['updateDate'] = entity.updateDate;
  data['deleted'] = entity.deleted;
  data['isExpand'] = entity.isExpand;
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  return data;
}

extension PrincipalResponsibilitiesListEntityExtension on PrincipalResponsibilitiesListEntity {
  PrincipalResponsibilitiesListEntity copyWith({
    String? id,
    String? companyCode,
    String? typeName,
    dynamic path,
    String? parentId,
    String? createBy,
    dynamic createById,
    String? createDate,
    String? updateBy,
    dynamic updateById,
    String? updateDate,
    String? deleted,
    bool? isExpand,
    List<PrincipalResponsibilitiesListEntity>? children,
  }) {
    return PrincipalResponsibilitiesListEntity()
      ..id = id ?? this.id
      ..companyCode = companyCode ?? this.companyCode
      ..typeName = typeName ?? this.typeName
      ..path = path ?? this.path
      ..parentId = parentId ?? this.parentId
      ..createBy = createBy ?? this.createBy
      ..createById = createById ?? this.createById
      ..createDate = createDate ?? this.createDate
      ..updateBy = updateBy ?? this.updateBy
      ..updateById = updateById ?? this.updateById
      ..updateDate = updateDate ?? this.updateDate
      ..deleted = deleted ?? this.deleted
      ..isExpand = isExpand ?? this.isExpand
      ..children = children ?? this.children;
  }
}
